package com.student.teacher.repository;

import com.student.common.entity.Teacher;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * 教师数据访问接口
 * 
 * @author student
 * @date 2025
 */
@Repository
public interface TeacherRepository extends JpaRepository<Teacher, String> {
    
    /**
     * 根据条件查询教师
     */
    @Query("SELECT t FROM Teacher t WHERE " +
           "(:name IS NULL OR t.name LIKE %:name%) AND " +
           "(:title IS NULL OR t.title LIKE %:title%) AND " +
           "(:department IS NULL OR t.department LIKE %:department%) AND " +
           "(:employeeId IS NULL OR t.teacherId LIKE %:employeeId%) AND " +
           "(:status IS NULL OR t.status = :status)")
    Page<Teacher> findByConditions(@Param("name") String name, 
                                  @Param("title") String title, 
                                  @Param("department") String department,
                                  @Param("employeeId") String employeeId,
                                  @Param("status") String status,
                                  Pageable pageable);
}
